package com.lagou.cluster.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("login")
public class LoginController {

    @RequestMapping("toLogin")
    public String toLogin() {
        System.out.println("================++++++++++++++跳转登录页面");
        return "login";
    }


    @RequestMapping("/loginSystem")
    public String login(HttpServletRequest request, String username, String password) {

        if(!("admin".equals(username) && "admin".equals(password))) {

            System.out.println("非法，跳转");
            return "redirect:/login/toLogin";

        }

        System.out.println("合法用户");
        request.getSession().setAttribute("user", username);

        return "redirect:/resume";
    }


}
